#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <stdbool.h>

volatile sig_atomic_t keep_running = 1;

void handle_sigint(int sig)
{
    printf("\ncaught SIGINT, igore it\n");
}
    
void handle_sigterm(int sig)
{
    printf("\nreceived SIGTERM, exiting...\n");
    keep_running = 0;
}

int main()
{
    signal(SIGINT, handle_sigint);
    signal(SIGTERM, handle_sigterm);

    while(keep_running)
    {
        printf("running...\n");
        sleep(1);
    }

    printf("shutdown complete.\n");
    return 0;
}
